/*-+-*****************************************************************************
 Copyright (C) 2009-2012 Oceanside Software Corporation (R)
 Dallas, Texas

 Author       : Jason T. Brower
 Purpose      : This file is part of a point-of-sale software package
                originally written for Table-Service Restaurants.
              
 Date         : July 8th of 2012
              
 History      : The application that this software file belongs to was 
                written over a 3-Year period.  The first version was written
                in C# .Net 3.5 using Windows Forms.  Being new to .Net at
                the time, I soon learned of Windows Presentation Foundation,
                liked the graphics capabilities and databinding so I
                migrated to WPF.  When the .Net 4.0 framework was released
                the application was migrated from 3.5 to 4.0. Now today,
                .Net 4.5 RC is out and I was already in process of migrating
                before I made this public.
                
Excuse Me     : Please excuse the coding style, it is not representative of
                my typical work.  During the three years I was under a very
                tight budget, constantly running out of funding and was 
                working 18 hour days hyped up on 5-Hour Energy.  The 
                design is not textbook.  It is monolythic because of
                previous issues I will not get into.  There are few comments
                in the code and the ones that are there may be incorrect.
                
What it is not: This is not the exact version that I took through PA-DSS 2.0
                nor is it the exact version running at my customer sites.
                I removed some details for security purposes including some
                encryption algorithms.  The reporting was removed because
                I was including a third party library that cannot be 
                published with this Open Source.
                
What it is    : This application has been running at high volume restaraunts
                for over a year.  It never freezes, crashes or does anything
                unexpected.  So long as it is built, installed and configured
                correctly, it is a strong system that we can all enhance.

Contact       : Please note that I can no longer work for free.  However, you
                can reach me at information@oceansidesw.com.                                                      

*********************************************************************************/
using System.Windows.Controls;
using System.Windows.Controls.Primitives;
using System;
using System.Windows;
using System.Windows.Media;
using System.Collections.Generic;
namespace Oceanside
{
    /// <summary>
    /// Interaction logic for PlaceOrderWindowInstance.xaml
    /// </summary>
    public partial class QuickOrderWindow : PosWindow
    {
        private QuickOrderWindow()
            : base()
        {
            this.InitializeComponent();
            this.Height = PosWindow.MainPosWindow.Height;
            this.Width = PosWindow.MainPosWindow.Width;

            ///Prevent the listview from resizing the columns.
            this.listViewCustTicket.AddHandler(Thumb.DragDeltaEvent, new DragDeltaEventHandler(Functions.Thumb_DragDelta), true);
            this.listViewCustTicket.MouseDoubleClick +=
                new System.Windows.Input.MouseButtonEventHandler(Functions.ListViewCustTicket_MouseDoubleClick);

            this.bCloserOrder.ButtonBackground = new SolidColorBrush(Color.FromRgb(0x46, 0xCD, 0x00));
        }

        static List<WrapPanel> _wrapPanels = new List<WrapPanel>();
        public static List<WrapPanel> WrapPanels
        {
            get { return QuickOrderWindow._wrapPanels; }
            set { QuickOrderWindow._wrapPanels = value; }
        }

        static QuickOrderWindow singleton = null;
        public static QuickOrderWindow Singleton
        {
            get { return QuickOrderWindow.singleton; }
            set { QuickOrderWindow.singleton = value; }
        }
        static QuickOrderWindow()
        {
            singleton = new QuickOrderWindow();
            WrapPanels.Add(Singleton.w1);
            WrapPanels.Add(Singleton.w2);
            WrapPanels.Add(Singleton.w3);
        }
        private static System.Action prepareForScreenChangeAction;
        public static System.Action PrepareForScreenChangeAction
        {
            get { return prepareForScreenChangeAction; }
            set { prepareForScreenChangeAction = value; }
        }

        private static System.Action prepareForScreenLeaveAction;
        public static System.Action PrepareForScreenLeaveAction
        {
            get { return prepareForScreenLeaveAction; }
            set { prepareForScreenLeaveAction = value; }
        }
        /// <summary>
        /// 
        /// </summary>
        public override void PrepareForScreenLeave()
        {
            PrepareForScreenLeaveAction();
        }

        public static FlatButton_52_58 SeatPosition1
        {
            get { return singleton.buttonSeatPosOne; }
        }

        public static Border OrderBorder
        {
            get { return singleton.orderBorder; }
        }

        public static FlatButton_52_58 SeatPosition2
        {
            get { return singleton.buttonSeatPosTwo; }
        }
        public static FlatButton_52_58 SeatPosition3
        {
            get { return singleton.buttonSeatPosThree; }
        }

        public static FlatButton_52_58 SeatPosition4
        {
            get { return singleton.buttonSeatPosFour; }
        }

        public static ShineButton_52_58 ScrollSeatLeft
        {
            get { return singleton.buttonScrollSeatLeft; }
        }

        public static ShineButton_52_58 ScrollSeatRight
        {
            get { return singleton.buttonScrollSeatRight; }
        }

        public static ShineButton_155_58 ScrollMainMenuUPButton
        {
            get { return singleton.buttonMainScrollUp; }
        }

        public static ShineButton_155_58 ScrollMainMenuDownButton
        {
            get { return singleton.buttonMainScrollDown; }
        }
        public static TextBlock TbModifyMessage
        {
            get { return singleton.textBlockModifyMessage; }
        }
        public static Grid GridModifyMessage
        {
            get { return singleton.gridModifyMessageBox; }
        }
        public static ShineButton_155_58 ScollSubMenuUpButton
        {
            get { return singleton.buttonSubmenuUp; }
        }
        public static ShineButton_155_58 ScollSubMenuDownButton
        {
            get { return singleton.buttonSubmenuDown; }
        }
        /// <summary>
        /// 
        /// </summary>
        public static WrapPanel PanelTopFunctions
        {
            get { return singleton.wrapPanelTopFunc; }
        }

        /// <summary>
        /// 
        /// </summary>
        public static WrapPanel PanelBottomFunctions
        {
            get { return singleton.wrapPanelBottomFunc; }
        }

        /// <summary>
        /// 
        /// </summary>
        public static WrapPanel PanelAuxFunctions
        {
            get { return singleton.wrapPanelAuxFunctions; }
        }

        public static StackPanel MainMenuStack
        {
            get { return singleton.mainMenuStack; }
        }

        public static WrapPanel SubMenuWrap
        {
            get { return singleton.subMenuwrapPanel; }
        }

        public static Button_95_50 CloseTableButton
        {
            get { return singleton.bCloserOrder; }
        }

        public static Label TableNumberLabel
        {
            get { return singleton.labelTableNumber; }
        }

        public static ListView CustomerTicketListView
        {
            get { return singleton.listViewCustTicket; }
        }

        public static ListView CustomerCheckTotal
        {
            get { return singleton.listviewCheckTotal; }
        }
        private static BindInterface _excptnModButtonBinding;
        public static BindInterface ExcptnModButtonBinding
        {
            get { return _excptnModButtonBinding; }
            set { _excptnModButtonBinding = value; }
        }

        /// <summary>
        /// 
        /// </summary>
        public override void PrepareForScreenChange()
        {
            PrepareForScreenChangeAction();
        }


        /// <summary>
        /// 
        /// </summary>
        public static void Show()
        {
            SwitchWindowDelegate_NOTHROW(singleton);
        }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="o"></param>
        public static void AssignDataContext(object o)
        {
            singleton.DataContext = o;
        }

        /// <summary>
        /// 
        /// </summary>
        /// <param name="tc"></param>
        public static void AddInstanceToTabControl(ref TabControl tc)
        {
            tc.Items.Add(singleton);
        }

        /// <summary>
        /// 
        /// </summary>
        /// <param name="index"></param>
        public static void SetTabIndex(int index)
        {
            singleton.MyTabIndex = index;
        }

        /// <summary>
        /// 
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void ButtonDown(object sender, System.Windows.Input.MouseButtonEventArgs e)
        {
            try
            {
                e.Handled = true;
                UserControl uc = sender as UserControl;
                int index = System.Convert.ToInt32(uc.Tag);
                PosWindow.PoListBoundFunctions[index].Clicked();
            }
            catch (System.Exception ex)
            {
                Constants.ErrorDispatcher.Notify(Error.EType.E_POBIND_CALL_BOUND_FUNC, ex);
            }
        }
    }
}
